package cn.wolfcode.crm.service.imp;


import cn.wolfcode.crm.domain.Depot;
import cn.wolfcode.crm.mapper.DepotMapper;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.IDepotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepotServiceImpl implements IDepotService {
    @Autowired
    private DepotMapper depotMapper;
    @Override

    public void deleteByPrimaryKey(Long id) {
        if (id != null) {
            depotMapper.deleteByPrimaryKey(id);
        }
    }

    @Override

    public void saveOrUpdate(Depot depot) {
        if (depot.getId() != null) {
            //update
            depotMapper.updateByPrimaryKey(depot);
        }else {
            depotMapper.insert(depot);
        }
    }

    @Override
    public Depot selectByPrimaryKey(Long id) {

            Depot dept = depotMapper.selectByPrimaryKey(id);
        return dept;

    }

    @Override
    public List<Depot> selectAll() {
        List<Depot> depots = depotMapper.selectAll();
        return depots;
    }

    @Override
    public void changeState(Long depotID) {
        depotMapper.changeState(depotID);
    }
}
